<?php

// 获取前端传过来的用户名和密码
// 数据插入数据库

$name = $_POST['name'];
$pwd = $_POST['pwd'];

$conn = mysqli_connect('localhost', 'root', 'root', '2008');
mysqli_query($conn, "set charset 'utf8'");
mysqli_query($conn, "set character set 'utf8'");

// 写sql语句，变量类型是字符串的还得再单独加单引号
$sql = "insert into user (name,pwd) values ('$name','$pwd')";

$res = mysqli_query($conn, $sql);

if ($res) {
  echo '注册成功，去<a href="../../html/login.html">登录</a>';
} else {
  echo '注册失败，请重试';
}


?>